Attribute VB_Name = "modConversions"
'---------------------------------------------------------------------------------------
'Module : modConversions
'Date   : 07/14/2004
'Author : Chris Elwell
'Purpose: Routines to convert Country codes and Service Type names.
'---------------------------------------------------------------------------------------
'
'---------------------------------------------------------------------------------------
' Procedure : ConvertCountryCode
' DateTime  : 03/17/2004
' Modified   : 01/06/2005 - Not returning Country Code. Added line to set function = to strCountry
' Purpose   : This function converts the customer country code into standard 2-character
'             country code.
' Call from :
'---------------------------------------------------------------------------------------
'
Public Function ConvertCountryCode(ByVal strCountry As String) As String

    On Error GoTo EH
    g_strErrorLocation = "modConversions:ConvertCountryCode"
    
    Select Case UCase(Trim(strCountry))
        Case "USA", "U.S.A.", "UNITED STATES"
            strCountry = "US"          'UNITED STATES
        Case "MICRONESIA"
            strCountry = "FM"          'MICRONESIA
        Case "FAEROE ISLANDS"
            strCountry = "FO"          'FAEROE ISLANDS
        Case "FRANCE"
            strCountry = "FR"          'FRANCE
        Case "GABON"
            strCountry = "GA"          'GABON
        Case "UNITED KINGDOM"
            strCountry = "GB"          'UNITED KINGDOM
        Case "GRENADA"
            strCountry = "GD"          'GRENADA
        Case "GEORGIA"
            strCountry = "GE"          'GEORGIA
        Case "FRENCH GUIANA"
            strCountry = "GF"          'FRENCH GUIANA
        Case "GHANA"
            strCountry = "GH"          'GHANA
        Case "GIBRALTAR"
            strCountry = "GI"          'GIBRALTAR
        Case "GREENLAND"
            strCountry = "GL"          'GREENLAND
        Case "GAMBIA"
            strCountry = "GM"          'GAMBIA
        Case "GUINEA"
            strCountry = "GN"          'GUINEA
        Case "GUADELOUPE"
            strCountry = "GP"          'GUADELOUPE
        Case "EQUATORIAL GUINEA"
            strCountry = "GQ"          'EQUATORIAL GUINEA
        Case "GREECE"
            strCountry = "GR"          'GREECE
        Case "GUATEMALA"
            strCountry = "GT"          'GUATEMALA
        Case "GUAM"
            strCountry = "GU"          'GUAM
        Case "GUYANA"
            strCountry = "GY"          'GUYANA
        Case "HONG KONG"
            strCountry = "HK"          'HONG KONG
        Case "HONDURAS"
            strCountry = "HN"          'HONDURAS
        Case "CROATIA"
            strCountry = "HR"          'CROATIA
        Case "HAITI"
            strCountry = "HT"          'HAITI
        Case "HUNGARY"
            strCountry = "HU"          'HUNGARY
        Case "INDONESIA"
            strCountry = "ID"          'INDONESIA
        Case "IRELAND"
            strCountry = "IE"          'IRELAND
        Case "ISRAEL"
            strCountry = "IL"          'ISRAEL
        Case "INDIA"
            strCountry = "IN"          'INDIA
        Case "ICELAND"
            strCountry = "IS"          'ICELAND
        Case "ITALY"
            strCountry = "IT"          'ITALY
        Case "JAMAICA"
            strCountry = "JM"          'JAMAICA
        Case "JORDAN"
            strCountry = "JO"          'JORDAN
        Case "JAPAN"
            strCountry = "JP"          'JAPAN
        Case "KENYA"
            strCountry = "KE"          'KENYA
        Case "KYRGYZSTAN"
            strCountry = "KG"          'KYRGYZSTAN
        Case "CAMBODIA"
            strCountry = "KH"          'CAMBODIA
        Case "ST. KITTS AND NEVIS"
            strCountry = "KN"          'ST. KITTS AND NEVIS
        Case "SOUTH KOREA"
            strCountry = "KR"          'SOUTH KOREA
        Case "KUWAIT"
            strCountry = "KW"          'KUWAIT
        Case "CAYMAN ISLANDS"
            strCountry = "KY"          'CAYMAN ISLANDS
        Case "KAZAKHSTAN"
            strCountry = "KZ"          'KAZAKHSTAN
        Case "LAOS"
            strCountry = "LA"          'LAOS
        Case "LEBANON"
            strCountry = "LB"          'LEBANON
        Case "ST. LUCIA"
            strCountry = "LC"          'ST. LUCIA
        Case "LIECHTENSTEIN"
            strCountry = "LI"          'LIECHTENSTEIN
        Case "SRI LANKA"
            strCountry = "LK"          'SRI LANKA
        Case "LIBERIA"
            strCountry = "LR"          'LIBERIA
        Case "LESOTHO"
            strCountry = "LS"          'LESOTHO
        Case "LITHUANIA"
            strCountry = "LT"          'LITHUANIA
        Case "LUXEMBOURG"
            strCountry = "LU"          'LUXEMBOURG
        Case "LATVIA"
            strCountry = "LV"          'LATVIA
        Case "MOROCCO"
            strCountry = "MA"          'MOROCCO
        Case "MONACO"
            strCountry = "MC"          'MONACO
        Case "MOLDOVA"
            strCountry = "MD"          'MOLDOVA
        Case "MADAGASCAR"
            strCountry = "MG"          'MADAGASCAR
        Case "MARSHALL ISLANDS"
            strCountry = "MH"          'MARSHALL ISLANDS
        Case "MACEDONIA"
            strCountry = "MK"          'MACEDONIA
        Case "MALI"
            strCountry = "ML"          'MALI
        Case "MONGOLIA"
            strCountry = "MN"          'MONGOLIA
        Case "MACAU"
            strCountry = "MO"          'MACAU
        Case "ANDORRA"
            strCountry = "AD"          'ANDORRA
        Case "UNITED ARAB EMIRATES"
            strCountry = "AE"          'UNITED ARAB EMIRATES
        Case "ANTIGUA"
            strCountry = "AG"          'ANTIGUA
        Case "ANGUILLA"
            strCountry = "AI"          'ANGUILLA
        Case "ALBANIA"
            strCountry = "AL"          'ALBANIA
        Case "ARMENIA"
            strCountry = "AM"          'ARMENIA
        Case "NETHERLANDS ANTILLES"
            strCountry = "AN"          'NETHERLANDS ANTILLES
        Case "ANGOLA"
            strCountry = "AO"          'ANGOLA
        Case "ARGENTINA"
            strCountry = "AR"          'ARGENTINA
        Case "AMERICAN SAMOA"
            strCountry = "AS"          'AMERICAN SAMOA
        Case "AUSTRIA"
            strCountry = "AT"          'AUSTRIA
        Case "AUSTRALIA"
            strCountry = "AU"          'AUSTRALIA
        Case "ARUBA"
            strCountry = "AW"          'ARUBA
        Case "AZERBAIJAN"
            strCountry = "AZ"          'AZERBAIJAN
        Case "BOSNIA-HERZEGOVINA"
            strCountry = "BA"          'BOSNIA-HERZEGOVINA
        Case "BARBADOS"
            strCountry = "BB"          'BARBADOS
        Case "BANGLADESH"
            strCountry = "BD"          'BANGLADESH
        Case "BELGIUM"
            strCountry = "BE"          'BELGIUM
        Case "BURKINA FASO"
            strCountry = "BF"          'BURKINA FASO
        Case "BULGARIA"
            strCountry = "BG"          'BULGARIA
        Case "BAHRAIN"
            strCountry = "BH"          'BAHRAIN
        Case "BURUNDI"
            strCountry = "BI"          'BURUNDI
        Case "BENIN"
            strCountry = "BJ"          'BENIN
        Case "BERMUDA"
            strCountry = "BM"          'BERMUDA
        Case "BRUNEI"
            strCountry = "BN"          'BRUNEI
        Case "BOLIVIA"
            strCountry = "BO"          'BOLIVIA
        Case "BRAZIL"
            strCountry = "BR"          'BRAZIL
        Case "BAHAMAS"
            strCountry = "BS"          'BAHAMAS
        Case "BHUTAN"
            strCountry = "BT"          'BHUTAN
        Case "BOTSWANA"
            strCountry = "BW"          'BOTSWANA
        Case "BELARUS"
            strCountry = "BY"          'BELARUS
        Case "BELIZE"
            strCountry = "BZ"          'BELIZE
        Case "CANADA"
            strCountry = "CA"          'CANADA
        Case "CONGO"
            strCountry = "CD"          'CONGO
        Case "CONGO"
            strCountry = "CG"          'CONGO
        Case "SWITZERLAND"
            strCountry = "CH"          'SWITZERLAND
        Case "IVORY COAST"
            strCountry = "CI"          'IVORY COAST
        Case "COOK ISLANDS"
            strCountry = "CK"          'COOK ISLANDS
        Case "CHILE"
            strCountry = "CL"          'CHILE
        Case "CAMEROON"
            strCountry = "CM"          'CAMEROON
        Case "CHINA"
            strCountry = "CN"          'CHINA
        Case "COLOMBIA"
            strCountry = "CO"          'COLOMBIA
        Case "COSTA RICA"
            strCountry = "CR"          'COSTA RICA
        Case "CAPE VERDE"
            strCountry = "CV"          'CAPE VERDE
        Case "CYPRUS"
            strCountry = "CY"          'CYPRUS
        Case "CZECH REPUBLIC"
            strCountry = "CZ"          'CZECH REPUBLIC
        Case "GERMANY"
            strCountry = "DE"          'GERMANY
        Case "DJIBOUTI"
            strCountry = "DJ"          'DJIBOUTI
        Case "DENMARK"
            strCountry = "DK"          'DENMARK
        Case "DOMINICA"
            strCountry = "DM"          'DOMINICA
        Case "DOMINICAN REPUBLIC"
            strCountry = "DO"          'DOMINICAN REPUBLIC
        Case "ECUADOR"
            strCountry = "EC"          'ECUADOR
        Case "ESTONIA"
            strCountry = "EE"          'ESTONIA
        Case "EGYPT"
            strCountry = "EG"          'EGYPT
        Case "ERITREA"
            strCountry = "ER"          'ERITREA
        Case "SPAIN"
            strCountry = "ES"          'SPAIN
        Case "ETHIOPIA"
            strCountry = "ET"          'ETHIOPIA
        Case "FINLAND"
            strCountry = "FI"          'FINLAND
        Case "FIJI"
            strCountry = "FJ"          'FIJI
        Case "SAIPAN"
            strCountry = "MP"          'SAIPAN
        Case "MARTINIQUE"
            strCountry = "MQ"          'MARTINIQUE
        Case "MAURITANIA"
            strCountry = "MR"          'MAURITANIA
        Case "MONTSERRAT"
            strCountry = "MS"          'MONTSERRAT
        Case "MALTA"
            strCountry = "MT"          'MALTA
        Case "MAURITIUS"
            strCountry = "MU"          'MAURITIUS
        Case "MALDIVES"
            strCountry = "MV"          'MALDIVES
        Case "MALAWI"
            strCountry = "MW"          'MALAWI
        Case "MEXICO"
            strCountry = "MX"          'MEXICO
        Case "MALAYSIA"
            strCountry = "MY"          'MALAYSIA
        Case "MOZAMBIQUE"
            strCountry = "MZ"          'MOZAMBIQUE
        Case "NAMIBIA"
            strCountry = "NA"          'NAMIBIA
        Case "NEW CALEDONIA"
            strCountry = "NC"          'NEW CALEDONIA
        Case "NIGER"
            strCountry = "NE"          'NIGER
        Case "NIGERIA"
            strCountry = "NG"          'NIGERIA
        Case "NICARAGUA"
            strCountry = "NI"          'NICARAGUA
        Case "NETHERLANDS"
            strCountry = "NL"          'NETHERLANDS
        Case "NORWAY"
            strCountry = "NO"          'NORWAY
        Case "NEPAL"
            strCountry = "NP"          'NEPAL
        Case "NEW ZEALAND"
            strCountry = "NZ"          'NEW ZEALAND
        Case "OMAN"
            strCountry = "OM"          'OMAN
        Case "PANAMA"
            strCountry = "PA"          'PANAMA
        Case "PERU"
            strCountry = "PE"          'PERU
        Case "FRENCH POLYNESIA"
            strCountry = "PF"          'FRENCH POLYNESIA
        Case "PAPUA NEW GUINEA"
            strCountry = "PG"          'PAPUA NEW GUINEA
        Case "PHILIPPINES"
            strCountry = "PH"          'PHILIPPINES
        Case "PAKISTAN"
            strCountry = "PK"          'PAKISTAN
        Case "POLAND"
            strCountry = "PL"          'POLAND
        Case "PUERTO RICO"
            strCountry = "PR"          'PUERTO RICO
        Case "PALESTINE"
            strCountry = "PS"          'PALESTINE
        Case "PORTUGAL"
            strCountry = "PT"          'PORTUGAL
        Case "PALAU"
            strCountry = "PW"          'PALAU
        Case "PARAGUAY"
            strCountry = "PY"          'PARAGUAY
        Case "QATAR"
            strCountry = "QA"          'QATAR
        Case "REUNION"
            strCountry = "RE"          'REUNION
        Case "ROMANIA"
            strCountry = "RO"          'ROMANIA
        Case "RUSSIA"
            strCountry = "RU"          'RUSSIA
        Case "RWANDA"
            strCountry = "RW"          'RWANDA
        Case "SAUDI ARABIA"
            strCountry = "SA"          'SAUDI ARABIA
        Case "SEYCHELLES"
            strCountry = "SC"          'SEYCHELLES
        Case "SWEDEN"
            strCountry = "SE"          'SWEDEN
        Case "SINGAPORE"
            strCountry = "SG"          'SINGAPORE
        Case "SLOVENIA"
            strCountry = "SI"          'SLOVENIA
        Case "SLOVAK REPUBLIC"
            strCountry = "SK"          'SLOVAK REPUBLIC
        Case "SENEGAL"
            strCountry = "SN"          'SENEGAL
        Case "SURINAME"
            strCountry = "SR"          'SURINAME
        Case "EL SALVADOR"
            strCountry = "SV"          'EL SALVADOR
        Case "SYRIA"
            strCountry = "SY"          'SYRIA
        Case "SWAZILAND"
            strCountry = "SZ"          'SWAZILAND
        Case "TURKS AND CAICOS ISLANDS"
            strCountry = "TC"          'TURKS AND CAICOS ISLANDS
        Case "CHAD"
            strCountry = "TD"          'CHAD
        Case "TOGO"
            strCountry = "TG"          'TOGO
        Case "THAILAND"
            strCountry = "TH"          'THAILAND
        Case "TURKMENISTAN"
            strCountry = "TM"          'TURKMENISTAN
        Case "TUNISIA"
            strCountry = "TN"          'TUNISIA
        Case "TURKEY"
            strCountry = "TR"          'TURKEY
        Case "TRINIDAD AND TOBAGO"
            strCountry = "TT"          'TRINIDAD AND TOBAGO
        Case "TAIWAN"
            strCountry = "TW"          'TAIWAN
        Case "TANZANIA"
            strCountry = "TZ"          'TANZANIA
        Case "UKRAINE"
            strCountry = "UA"          'UKRAINE
        Case "UGANDA"
            strCountry = "UG"          'UGANDA
        Case "URUGUAY"
            strCountry = "UY"          'URUGUAY
        Case "UZBEKISTAN"
            strCountry = "UZ"          'UZBEKISTAN
        Case "VATICAN CITY"
            strCountry = "VA"          'VATICAN CITY
        Case "ST. VINCENT"
            strCountry = "VC"          'ST. VINCENT
        Case "VENEZUELA"
            strCountry = "VE"          'VENEZUELA
        Case "BRITISH VIRGIN ISLANDS"
            strCountry = "VG"          'BRITISH VIRGIN ISLANDS
        Case "U S VIRGIN ISLANDS"
            strCountry = "VI"          'U S VIRGIN ISLANDS
        Case "VIETNAM"
            strCountry = "VN"          'VIETNAM
        Case "VANUATU"
            strCountry = "VU"          'VANUATU
        Case "WALLIS & FUTUNA"
            strCountry = "WF"          'WALLIS & FUTUNA
        Case "YEMEN"
            strCountry = "YE"          'YEMEN
        Case "YUGOSLAVIA"
            strCountry = "YU"          'YUGOSLAVIA
        Case "SOUTH AFRICA"
            strCountry = "ZA"          'SOUTH AFRICA
        Case "ZAMBIA"
            strCountry = "ZM"          'ZAMBIA
        Case "ZIMBABWE"
            strCountry = "ZW"          'ZIMBABWE
        Case Else
            strCountry = strCountry
    End Select
       
    'Added 1/6/05
    ConvertCountryCode = strCountry
    
    Exit Function
EH:
     MsgBox Err.Description, vbCritical, g_strErrorLocation

End Function
'---------------------------------------------------------------------------------------
' Procedure : ConvertServiceType()
' DateTime  : 6/9/2004
' Purpose   : Called from BuildCommonFlds if chkConvertSvcCodes is checked on the Service
'             Conv tab on frmSetup. Converts the customer defined service names to FedEx
'             Service Codes.
'---------------------------------------------------------------------------------------
'
Public Function ConvertServiceType(ByVal strService As String) As String

    On Error GoTo EH
    g_strErrorLocation = "modConversions:ConvertServiceType"
    
    Dim i As Integer
    Dim strSvcCodes(17) As String
    
    strSvcCodes(0) = "06"       'First Overnight
    strSvcCodes(1) = "01"       'Priority Overnight
    strSvcCodes(2) = "05"       'Standard Overnight
    strSvcCodes(3) = "03"       '2-Day
    strSvcCodes(4) = "20"       'Express Saver
    strSvcCodes(5) = "92"       'Ground
    strSvcCodes(6) = "90"       'Home Delivery
    strSvcCodes(7) = "70"       '1 Day Freight
    strSvcCodes(8) = "80"       '2 Day Freight
    strSvcCodes(9) = "83"       '3 Day Freight
    strSvcCodes(10) = "06"       'Intl First
    strSvcCodes(11) = "01"       'Intl Priority
    strSvcCodes(12) = "03"       'Intl Economy
    strSvcCodes(13) = "06"       'Intl Priority Freight
    strSvcCodes(14) = "06"       'Intl Economy Freight
    strSvcCodes(15) = "92"       'Ground (CA Only)
    strSvcCodes(16) = "90"       'Home Delivery (CA Only)
    
    For i = 0 To 16
        If UCase(Trim(strService)) = UCase(Trim(frmSetup.txtCustSvcCode(i))) Then
            strService = strSvcCodes(i)
        End If
    Next
    
    ConvertServiceType = strService
    
    Exit Function
EH:
     MsgBox Err.Description, vbCritical, g_strErrorLocation

End Function


